import http from '@/utils/http'

// 加入购物车
export function reqAddCart({ skuId, count }) {
	return http.post('/member/cart', {
		skuId,
		count,
	})
}

// 获取购物车列表
export function reqCartList() {
	return http.get('/member/cart')
}

// 删除购物车商品
export function reqDeleteCartGoods(ids) {
	return http.delete('/member/cart', {
		data: {
			ids,
		},
	})
}

// 合并本地添加的购物车数据至后端
export function reqMergeCart(data) {
	return http.post('/member/cart/merge', data)
}

// 修改购物车全选状态或取消全选状态
export function reqCartGoodsAllSelect(data) {
	return http.put('/member/cart/selected', data)
}

// 修改购物车商品, 选中状态和数量
export function reqUpdateCartGoodsState({ selected, count, id }) {
	return http.put(`/member/cart/${id}`, {
		selected,
		count,
	})
}
